<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
     <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>离职员工报表</title>

    <!-- Bootstrap -->
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->



  </head>
  <body>
<!-- 导航 -->
    <nav class="navbar navbar-default ">
      <div class="container">
        <!-- 小屏幕按钮和logo -->
        <div class="navbar-header">
          <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a href="#" class="navbar-brand">RM admin</a>
        </div>
        <!-- 小屏幕按钮和logo -->
        <!-- 导航 -->
        <div class="collapse navbar-collapse">
           <ul class=" nav navbar-nav ">
             <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> &nbsp;后台首页</a></li>
             <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    组织结构管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/organization/department">部门管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/organization/job">岗位管理</a></li>

                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    人事信息管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/employee/enterAddEmployee">员工入职管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/period/enterPeriod/">试用期管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/dept/out">部门调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/post/out">岗位调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/leave/out">员工离职管理</a></li>

                </ul>
            </li>
             <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    员工信息中心
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/infoemployee/list">员工信息中心</a></li>


                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    报表管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/statement/newHire">新聘员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/departure">离职员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/deptTurn">部门调动员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/postTurn">岗位调动员工报表</a></li>
                </ul>
            </li>
           </ul>
           <ul class=" nav navbar-nav navbar-right ">
             <li class="dropdown">
                <a href="#" class=" dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">admin
                    <span class="caret"></span>
                </a>
            </li>

             <li><a href="http://localhost:8080/PMsystem/admin/exit"><span class="glyphicon glyphicon-off"></span>&nbsp;退出</a></li>
           </ul>
        </div>
        <!-- 导航 -->
      </div>
    </nav>
   <!-- 导航 -->
   <div class="container-fluid">
       <div class="row">
           <div class="col-md-2">
               <div class="panel-group" id="accordion">
                                  <div class="panel panel-default">
                      <div class="panel-heading">
                          <h4 class="panel-title">
                              <a data-toggle="collapse" data-parent="#accordion"
                              href="#collapseThree" style="text-decoration: none;">
                             离职员工报表
                              </a>
                          </h4>
                      </div>
                      <div id="collapseThree" class="panel-collapse collapse in">
                          <div class="panel-body">
                              <table class="table table-hover">
                              <tbody>
                                <tr>
                                  <td style="border:none;"><a href="" style="text-decoration: none;">离职员工报表</a></td>
                                </tr>

                              </tbody>
                            </table>
                          </div>
                      </div>
                  </div>
              </div>

           </div>

           <div class="col-sm-10">
           <!-- 主体内容 -->
           <div class="panel panel-info">
              <div class="panel-heading">
                  <h3 class="panel-title">查询报表</h3>
              </div>
              <div class="panel-body">
                 <form class="form-inline" role="form" action="${pageContext.request.contextPath }/statement/departure" method="POST">
                    <div class="input-group">
                        <span class="input-group-addon">开始月份</span>
                        <input type="date" class="form-control" placeholder="请输入月份" name="nSDate" value="2018-01-01">

                    </div>--
                     <div class="input-group">
                        <span class="input-group-addon">结束月份</span>
                        <input type="date" class="form-control" placeholder="请输入月份" name="nEDate" value="2019-01-08">

                    </div>--
                    <div class="input-group">
                        <span class="input-group-addon">部门</span>
                        <select class="form-control" style="width: 200px;" name="deptName">
                        <c:forEach items="${department}" var="item">
                        	<option value="${item.deptName }">${item.deptName }</option>
                        </c:forEach>
                      
                      </select>
                        <span class="input-group-btn">
                              <button type="submit" class="btn btn-info">提交</button>
                          </span>
                    </div>


                  </form>
              </div>
          </div>
          <div class="panel panel-success">
              <div class="panel-heading">
                  <h3 class="panel-title">离职员工报表</h3>
              </div>
              <div class="panel-body">
                    <table id="tableExcel" class="table table-hover">

                         <thead>
                        <tr>
                          <th>序号</th>
                          <th>部门名称</th>
                          <th>岗位名称</th>
                          <th>姓名</th>
                          <th>性别</th>
                          <th>离职日期</th>
                          <th>离职原因</th>
                        </tr>
                      </thead>
                      <tbody>
                        <c:forEach items="${leaveEmployee }" var="leaveEmployee">
						   <tr>
							   <td>${leaveEmployee.elId }</td>
							   <td>${leaveEmployee.elDept.deptName }</td>
							   <td>${leaveEmployee.elPost.postName }</td>
							   <td>${leaveEmployee.elEmp.empName }</td>
							   <td>${leaveEmployee.elEmp.empSex }</td>
							   <td>${leaveEmployee.elDate }</td>
							   <td>${leaveEmployee.elType }</td>
						   </tr>
						   </c:forEach>
                      </tbody>

                      </table>
                      <button onClick="exportExcel('tableExcel')" type="button" class="btn">导出Excel文件</button>
                      
              </div>
          </div>


           </div>
       </div>


	<script language="JavaScript" type="text/javascript"> 
var idTmr; 
//获取当前浏览器类型 
function getExplorer() { 
	var explorer = window.navigator.userAgent ; 
	//ie 
	if (explorer.indexOf("MSIE") >= 0) { 
		return 'ie'; 
	} 
	//firefox 
	else if (explorer.indexOf("Firefox") >= 0) { 
		return 'Firefox'; 
	} 
	//Chrome 
	else if(explorer.indexOf("Chrome") >= 0){ 
		return 'Chrome'; 
	} 
	//Opera 
	else if(explorer.indexOf("Opera") >= 0){ 
		return 'Opera'; 
	} 
	//Safari 
	else if(explorer.indexOf("Safari") >= 0){ 
		return 'Safari'; 
	} 
}
    
//获取到类型需要判断当前浏览器需要调用的方法，目前项目中火狐，谷歌，360没有问题 
//win10自带的IE无法导出 
function exportExcel(tableid) { 
	if(getExplorer()=='ie') 
	{ 
		var curTbl = document.getElementById(tableid); 
		var oXL = new ActiveXObject("Excel.Application"); 
	    var oWB = oXL.Workbooks.Add(); 
	    var xlsheet = oWB.Worksheets(1); 
	    var sel = document.body.createTextRange(); 
	    sel.moveToElementText(curTbl); 
	    sel.select(); 
	    sel.execCommand("Copy"); 
	    xlsheet.Paste(); 
	    oXL.Visible = true; 
  
		try { 
			var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls"); 
		} catch (e) { 
			print("Nested catch caught " + e); 
		} finally { 
			oWB.SaveAs(fname); 
			oWB.Close(savechanges = false); 
			oXL.Quit(); 
			oXL = null; 
			idTmr = window.setInterval("Cleanup();", 1); 
		} 
  
	} 
	else 
	{ 
		tableToExcel(tableid) 
	} 
  } 
function Cleanup(){ 
	window.clearInterval(idTmr); 
	CollectGarbage(); 
} 
    
//判断浏览器后调用的方法，把table的id传入即可 
var tableToExcel = (function() { 
	var uri = 'data:application/vnd.ms-excel;base64,', 
	template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>', 
	base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }, 
	format = function(s, c) { 
	return s.replace(/{(\w+)}/g, 
	function(m, p) { return c[p]; }) } 
	return function(table, name) { 
	if (!table.nodeType) table = document.getElementById(table) 
	var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML} 
	window.location.href = uri + base64(format(template, ctx)) 
	} 
})() 
  
</script> 




    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->

    <script src="<%=basePath%>js/bootstrap.min.js"></script>

  </body>
</html>